package com.namit.gwtsite.server;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.ServletContextAware;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.namit.gwtsite.client.NamitKarlekar;

/**
 * The server side implementation of the RPC service.
 */
@RequestMapping("/mygwtsite")
@Controller
public class NamitKarlekarImpl extends RemoteServiceServlet implements
		NamitKarlekar, ServletContextAware {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private ServletContext sc;

	@RequestMapping("/asyncRequest.rpc")
	public void dummyHandler(HttpServletRequest request,
			HttpServletResponse response) {
		System.out.println("GreetingServiceImpl.dummyHandler()");
		super.doPost(request, response);
	}

	public String greetServer(String input) throws IllegalArgumentException {
		System.out.println("GreetingServiceImpl.greetServer()");

		return "";
	}

	public String anotherServiceCall(String dataIn)
			throws IllegalArgumentException {
		// TODO Auto-generated method stub
		return null;
	}

	public void setServletContext(ServletContext sc) {
		this.sc = sc;
	}

	@Override
	public ServletContext getServletContext() {
		return sc;
	}
}
